package chapter8.HomeWork;

public class Doctor {
    private String name;
    private int age;
    private String job;
    private String gender;
    private double sal;

    public Doctor(String name, int age, String job, String gender, double sal) {
        this.name = name;
        this.age = age;
        this.job = job;
        this.gender = gender;
        this.sal = sal;
    }

    @Override
    public boolean equals(Object obj) {
    //先判断是否是同一个对象
        if (this == obj) {
            return true;
        }
        //判断obj的运行类型是否是Doctor或其子类
        if (!(obj instanceof Doctor)){
            return false;
        }
        //向下转型
        Doctor doctor = (Doctor)obj;
        return this.name.equals(doctor.name)&&this.age ==doctor.age&&
                this.gender.equals(doctor.gender)&&this.job.equals(doctor.job)
                &&this.job.equals(doctor.job);
    }
}
